#ifndef NOFOCUSDELEGATE_H
#define NOFOCUSDELEGATE_H
#include <QStyledItemDelegate>
#include <QPainter>


class NoFocusDelegate : public QStyledItemDelegate
{
   Q_OBJECT
public:
    explicit NoFocusDelegate(){};
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    {
        QStyleOptionViewItem itemOption(option);
        QRect rectItem = itemOption.rect;

        if (itemOption.state & QStyle::State_HasFocus)
        {
           itemOption.state = itemOption.state ^ QStyle::State_HasFocus;
        }

        painter->setPen(QColor(Qt::lightGray));

        if(index.row() % 2 != 0)
        {
            painter->setBrush(QColor(238, 238, 236));
            painter->drawRect(rectItem);
        }
        else
        {
            painter->setBrush(QColor(255, 255, 255));
            painter->drawRect(rectItem);
        }

        QStyledItemDelegate::paint(painter, itemOption, index);
    };
};


#endif // NOFOCUSDELEGATE_H
